package com.centaline.androidsalesblog.utils;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

import com.centanet.framework.utils.SysUtil;

import java.util.Locale;

/**
 * 400util
 * Created by Lihq on 2016/2/25.
 */
public final class ContactUtil {

    private ContactUtil() {
        //Utility Class
    }

    public static boolean dial(Context context, String bigCode, String extCode) {
        if (TextUtils.isEmpty(bigCode)) {
            return false;
        } else if (TextUtils.isEmpty(extCode)) {
            dial(context, bigCode);
        } else {
            dial(context, String.format(Locale.CHINA, "%s,%s", bigCode, extCode));
        }
        return true;
    }

    /**
     * 拨打
     */
    public static void dial(Context context, String mobile) {
        context.startActivity(new Intent(Intent.ACTION_CALL,
                Uri.parse(String.format(Locale.CHINA, "tel:%s", mobile))));
    }

    /**
     * 短信
     *
     * @param strings 数组 第一个为手机号,第二个为短信内容
     */
    public static void sendMsg(Context context, String... strings) {
        if (strings == null || strings.length == 0)
            return;
        SysUtil.sendMsg(context, strings[0], strings.length == 1 || TextUtils.isEmpty(strings[1]) ? "" : strings[1]);
    }

}
